{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "ViewInteractiveWidget(height=1066, layout=Layout(height='auto', width='100%'), width=1066)"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "import vedo\n",
    "from numpy import array\n",
    "\n",
    "pore_data = {'radius': array([1.19674905, 1.17642665, 1.48423733, 4.11235865, 5.27399875,\n",
    "        1.6080488 , 5.04062365, 3.28250786, 0.48145194, 1.95844462,\n",
    "        2.95412234, 6.34223284, 2.68521829, 1.22652792, 1.89028428,\n",
    "        2.32453223, 2.37981034, 5.88536598, 4.78205451, 3.666239  ,\n",
    "        5.94103498, 5.94537754, 3.51141173, 5.69892518, 2.37635673,\n",
    "        1.56836145, 5.27402228, 2.67315768, 2.31724564, 2.92747411,\n",
    "        1.17457039, 1.1796397 , 0.27594236, 0.58774932, 0.37354945,\n",
    "        2.94445452, 0.43445867, 1.16996146, 1.12668883, 1.21957642]),\n",
    " 'center': array([[30., 15.,  3.],\n",
    "        [ 4., 47.,  3.],\n",
    "        [37.,  3.,  5.],\n",
    "        [42., 44.,  6.],\n",
    "        [16., 19.,  8.],\n",
    "        [32., 32., 10.],\n",
    "        [13., 41., 10.],\n",
    "        [37., 24., 12.],\n",
    "        [29., 45., 15.],\n",
    "        [40., 50., 16.],\n",
    "        [22., 49., 19.],\n",
    "        [16., 30., 21.],\n",
    "        [49., 34., 24.],\n",
    "        [35., 34., 28.],\n",
    "        [27.,  3., 29.],\n",
    "        [21.,  4., 30.],\n",
    "        [24., 15., 32.],\n",
    "        [42., 39., 36.],\n",
    "        [11., 20., 37.],\n",
    "        [29., 31., 37.],\n",
    "        [27., 46., 38.],\n",
    "        [12.,  7., 51.],\n",
    "        [46., 48., 52.],\n",
    "        [26., 46., 59.],\n",
    "        [38.,  4., 62.],\n",
    "        [40., 49., 63.],\n",
    "        [ 7., 38., 64.],\n",
    "        [49.,  4., 65.],\n",
    "        [48., 46., 65.],\n",
    "        [27., 24., 70.],\n",
    "        [50., 50., 70.],\n",
    "        [48., 50., 72.],\n",
    "        [12., 51., 72.],\n",
    "        [41., 36., 73.],\n",
    "        [43., 51., 73.],\n",
    "        [25.,  4., 74.],\n",
    "        [34., 25., 74.],\n",
    "        [43., 25., 75.],\n",
    "        [50., 33., 75.],\n",
    "        [45., 38., 75.]]),\n",
    " 'color': array([[ 0,  0,  0],\n",
    "        [ 1,  1,  1],\n",
    "        [ 2,  2,  2],\n",
    "        [ 3,  3,  3],\n",
    "        [ 4,  4,  4],\n",
    "        [ 5,  5,  5],\n",
    "        [ 6,  6,  6],\n",
    "        [ 7,  7,  7],\n",
    "        [ 8,  8,  8],\n",
    "        [ 9,  9,  9],\n",
    "        [10, 10, 10],\n",
    "        [11, 11, 11],\n",
    "        [12, 12, 12],\n",
    "        [13, 13, 13],\n",
    "        [14, 14, 14],\n",
    "        [15, 15, 15],\n",
    "        [16, 16, 16],\n",
    "        [17, 17, 17],\n",
    "        [18, 18, 18],\n",
    "        [19, 19, 19],\n",
    "        [20, 20, 20],\n",
    "        [21, 21, 21],\n",
    "        [22, 22, 22],\n",
    "        [23, 23, 23],\n",
    "        [24, 24, 24],\n",
    "        [25, 25, 25],\n",
    "        [26, 26, 26],\n",
    "        [27, 27, 27],\n",
    "        [28, 28, 28],\n",
    "        [29, 29, 29],\n",
    "        [30, 30, 30],\n",
    "        [31, 31, 31],\n",
    "        [32, 32, 32],\n",
    "        [33, 33, 33],\n",
    "        [34, 34, 34],\n",
    "        [35, 35, 35],\n",
    "        [36, 36, 36],\n",
    "        [37, 37, 37],\n",
    "        [38, 38, 38],\n",
    "        [39, 39, 39]]),\n",
    " 'pore_pressure': [0.0,\n",
    "  0.0,\n",
    "  0.0,\n",
    "  0.1,\n",
    "  10.0,\n",
    "  7.598155494738002,\n",
    "  10.0,\n",
    "  0.1,\n",
    "  0.0,\n",
    "  0.1,\n",
    "  4.9866234871525,\n",
    "  10.0,\n",
    "  0.1,\n",
    "  0.0,\n",
    "  10.0,\n",
    "  10.0,\n",
    "  9.999999999999998,\n",
    "  0.1,\n",
    "  10.0,\n",
    "  5.887868354558643,\n",
    "  4.512645435262695,\n",
    "  10.0,\n",
    "  0.1,\n",
    "  6.150712624490666,\n",
    "  6.885571232556974,\n",
    "  0.1,\n",
    "  10.0,\n",
    "  0.1,\n",
    "  0.1,\n",
    "  9.908732905890773,\n",
    "  0.1,\n",
    "  0.1,\n",
    "  0.0,\n",
    "  0.0,\n",
    "  0.0,\n",
    "  9.57065941647515,\n",
    "  0.0,\n",
    "  0.0,\n",
    "  0.0,\n",
    "  0.0]}\n",
    "\n",
    "throat_data = {'radius': array([2.90419237, 1.91412649, 4.95871637, 2.66664252, 3.84343485,\n",
    "        2.91695308, 2.64362353, 2.90442779, 2.16462804, 1.59391792,\n",
    "        2.89982681, 4.00869598, 2.20213635, 3.22351169, 2.33049898,\n",
    "        4.0408531 , 3.26135521, 3.53445357, 3.87389098, 5.70235662,\n",
    "        4.33497331, 3.67944754, 4.31956756, 1.54813143, 2.33478145,\n",
    "        3.54625105, 3.2341318 , 3.56343412, 2.91256156, 4.51513931,\n",
    "        3.03150832, 2.90332157, 3.13112118, 4.94121126, 3.87019909,\n",
    "        2.97949269, 2.96877147, 2.17017842, 2.16641068, 4.14354076,\n",
    "        4.05124284, 1.24314961, 2.60263205, 1.56828704, 2.91248637,\n",
    "        1.21171778, 1.54088758, 0.58485084, 1.84036701, 0.40036291]),\n",
    " 'throat_connection': array([[ 4,  6],\n",
    "        [ 3,  7],\n",
    "        [ 6, 11],\n",
    "        [ 6, 10],\n",
    "        [ 4, 11],\n",
    "        [ 4,  5],\n",
    "        [ 3,  9],\n",
    "        [ 4,  7],\n",
    "        [ 3, 12],\n",
    "        [ 5,  7],\n",
    "        [ 4, 14],\n",
    "        [ 7, 11],\n",
    "        [ 7, 12],\n",
    "        [ 7, 17],\n",
    "        [ 4, 17],\n",
    "        [10, 17],\n",
    "        [12, 17],\n",
    "        [ 4, 15],\n",
    "        [10, 20],\n",
    "        [17, 20],\n",
    "        [ 4, 18],\n",
    "        [11, 20],\n",
    "        [11, 19],\n",
    "        [14, 15],\n",
    "        [ 4, 16],\n",
    "        [11, 18],\n",
    "        [17, 19],\n",
    "        [15, 21],\n",
    "        [19, 20],\n",
    "        [18, 21],\n",
    "        [19, 21],\n",
    "        [20, 26],\n",
    "        [20, 22],\n",
    "        [20, 23],\n",
    "        [23, 26],\n",
    "        [21, 26],\n",
    "        [22, 23],\n",
    "        [22, 28],\n",
    "        [24, 27],\n",
    "        [21, 24],\n",
    "        [21, 35],\n",
    "        [25, 28],\n",
    "        [26, 29],\n",
    "        [24, 35],\n",
    "        [21, 29],\n",
    "        [28, 30],\n",
    "        [27, 35],\n",
    "        [30, 31],\n",
    "        [29, 35],\n",
    "        [38, 39]]),\n",
    "}\n",
    "\n",
    "throat_coordinates = list()\n",
    "throat_connectivity = throat_data['throat_connection']\n",
    "for throat_connection in throat_connectivity:\n",
    "    pore_i = throat_connection[0]\n",
    "    pore_j = throat_connection[1]\n",
    "    pore_i_coordinate = pore_data['center'][pore_i]\n",
    "    pore_j_coordinate = pore_data['center'][pore_j]\n",
    "    throat_coordinates.append((pore_i_coordinate, pore_j_coordinate))\n",
    "\n",
    "pores_rendering_list = list()\n",
    "for idx in range(len(pore_data['center'])):\n",
    "    pore_rendering = vedo.Sphere(\n",
    "        pos=pore_data['center'][idx],\n",
    "        r=pore_data['radius'][idx],\n",
    "        # c=pore_data['color'][idx] /50\n",
    "        c=vedo.colorMap(pore_data['pore_pressure'][idx], name='jet', vmin=0, vmax=10)\n",
    "    )\n",
    "    pores_rendering_list.append(pore_rendering)\n",
    "\n",
    "# just create a temporary Points and extract a scalarbar\n",
    "sb = vedo.Points(pore_data['center']\n",
    "                 ).cmap('jet', pore_data['pore_pressure']\n",
    "                        ).addScalarBar(c='k', title='pore\\npressure').scalarbar\n",
    "\n",
    "cylinder_radius_scale_factor = 0.5\n",
    "throats_rendering_list = list()\n",
    "for idx, throat_coordinate in enumerate(throat_coordinates):\n",
    "    cylinder_radius = cylinder_radius_scale_factor * throat_data['radius'][idx]\n",
    "    throats_rendering = vedo.Cylinder(\n",
    "        pos=(throat_coordinate[0], throat_coordinate[1]),\n",
    "        r=cylinder_radius,\n",
    "        c=vedo.colorMap(cylinder_radius, name='bone', vmin=0, vmax=5),\n",
    "    )\n",
    "    throats_rendering_list.append(throats_rendering)\n",
    "\n",
    "plt = vedo.show(*pores_rendering_list, *throats_rendering_list, sb, axes=1)\n",
    "plt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "plt.close()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
